package cn.com.infostrategy.ui.mdata;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.io.Serializable;

import javax.swing.Icon;
import javax.swing.JComponent;

public class QuickLocationUpDownBtn implements Icon, Serializable {
	private static final long serialVersionUID = -6107787266591623173L;

	int li_type = 0;
	Color bgColor = null;

	public QuickLocationUpDownBtn(int _type) {
		li_type = _type;
	}

	public QuickLocationUpDownBtn(int _type, Color _bgColor) {
		li_type = _type;
		bgColor = _bgColor;
	}

	public void paintIcon(Component c, Graphics g, int x, int y) {
		JComponent component = (JComponent) c;
		if (bgColor != null) {
			g.setColor(bgColor); //
			g.fillRect(0, 0, getIconWidth() * 2, getIconHeight() * 2); //
		}
		g.translate(x, y);
		g.setColor(new Color(135, 135, 135)); //
		if (li_type == 1) {
			g.drawLine(3, 3, 11, 3);
			g.drawLine(4, 4, 10, 4);
			g.drawLine(5, 5, 9, 5);
			g.drawLine(6, 6, 8, 6);
			g.drawLine(7, 7, 7, 7);
		} else if (li_type == 2) {
			g.drawLine(7, 2, 7, 2);
			g.drawLine(6, 3, 8, 3);
			g.drawLine(5, 4, 9, 4);
			g.drawLine(4, 5, 10, 5);
			g.drawLine(3, 6, 11, 6);
		}
		g.translate(-x, -y);
	}

	/**
	 * Created a stub to satisfy the interface.
	 */
	public int getIconWidth() {
		return 15;
	}

	/**
	 * Created a stub to satisfy the interface.
	 */
	public int getIconHeight() {
		return 10;
	}

}